<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/common/common.jsp" %>
<%
    String projectid = request.getParameter("prjid");

%>
<html>
<head>
<%@include file="/common/head.jsp" %>
    <script type="text/javascript" language="javascript" src="${ctx}/js/gantt/dhtmlxcommon.js"></script>
    <script type="text/javascript" language="javascript" src="${ctx}/js/gantt/dhtmlxgantt.js"></script>
    <link rel="stylesheet" type="text/css" href="${ctx}/js/gantt/dhtmlxgantt.css"/>
    <script type="text/javascript">
        GanttChart.prototype.getMonthScaleLabel = function (date) {
            return (this._useShortMonthNames ? this.shortMonthNames : this.monthNames)[date.getMonth()]
        };
        GanttProject.prototype.getPopUpInfo = function(object, event)
        {var posX = object.offsetLeft + ((event.layerX == null) ? event.offsetX : event.layerX);var posY = object.offsetTop + this.Chart.heightTaskItem + 6;var tblInfo = this.Chart.divInfo.lastChild;tblInfo.rows[0].cells[0].innerHTML = "<div style='font-family: Arial, Helvetica, Sans-serif;font-size: 12px;font-weight: bold;color: #688060;margin:0 0 4px 0;'>" + this.Project.Name + "</div>";tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>开始日期:&nbsp;</span><span class='ut'>" +this.Project.StartDate.getFullYear()+"-"+(this.Project.StartDate.getMonth() + 1) +"-"+ this.Project.StartDate.getDate()  + "</span><br/>";tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>周期:&nbsp;</span><span class='ut'>" + this.Duration + " 小时</span><br/>";tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>完成度:&nbsp;</span><span class='ut'>" + this.percentCompleted + "%</span><br/>";this.Chart.divInfo.style.cssText = "z-index:2;position: absolute;display: inline;";if (posY + this.Chart.divInfo.lastChild.offsetHeight + 6 > this.Chart.oData.offsetHeight + this.Chart.oData.scrollTop){this.Chart.divInfo.style.top = (posY - this.Chart.divInfo.lastChild.offsetHeight - 10 - this.Chart.heightTaskItem) + "px"}else {this.Chart.divInfo.style.top = posY + "px"};if (this.Chart.divInfo.lastChild.offsetWidth + posX + 10 > this.Chart.oData.offsetWidth + this.Chart.oData.scrollLeft){this.Chart.divInfo.style.left = posX - (this.Chart.divInfo.lastChild.offsetWidth + posX + 20 - (this.Chart.oData.offsetWidth + this.Chart.oData.scrollLeft)) + "px"}else {this.Chart.divInfo.style.left = posX + "px"}};
        GanttTask.prototype.getPopUpInfo = function(object, event)
        {var posY = object.offsetTop + this.Chart.heightTaskItem + 6;var posX = object.offsetLeft + ((event.layerX == null) ? event.offsetX : event.layerX);var tblInfo = this.Chart.divInfo.lastChild;tblInfo.rows[0].cells[0].innerHTML = "<div style='font-family: Arial, Helvetica, Sans-serif;font-size: 12px;font-weight: bold;color: #688060;margin: 0 0 4px 0;'>" + this.TaskInfo.Name + "</div>";tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>开始时间:&nbsp;</span><span class='ut'>" +  this.TaskInfo.EST.getFullYear() +"-"+(this.TaskInfo.EST.getMonth() + 1) + "-"+this.TaskInfo.EST.getDate() + "</span><br/>";tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>周期:&nbsp;</span><span class='ut'>" + this.TaskInfo.Duration + " 小时 </span><br/>";tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>完成度:&nbsp;</span><span class='ut'>" + this.TaskInfo.PercentCompleted + "% </span><br/>";if (this.predTask){tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>前置任务:&nbsp;</span>";tblInfo.rows[0].cells[0].innerHTML += "<span class='lt'>*" + this.TaskInfo.PredecessorTask.Name + "</span>"};if (this.TaskInfo.ChildTasks.length != 0){tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>Child Tasks:&nbsp;</span>";for (var i = 0;i < this.TaskInfo.ChildTasks.length;i++){tblInfo.rows[0].cells[0].innerHTML += (i == this.TaskInfo.ChildTasks.length - 1) ? ("<span class='lt'>*" + this.TaskInfo.ChildTasks[i].Name + "</span>") : ("<span class='lt'>*" + this.TaskInfo.ChildTasks[i].Name + "</span>")}};if (this.TaskInfo.ParentTask){tblInfo.rows[0].cells[0].innerHTML += "<span class='st'>Parent Task:&nbsp;</span>";tblInfo.rows[0].cells[0].innerHTML += "<span class='lt'>*" + this.TaskInfo.ParentTask.Name + "</span>"};this.Chart.divInfo.style.cssText = "z-index:2;position: absolute;display: inline;";if (posY + this.Chart.divInfo.lastChild.offsetHeight + 10 > this.Chart.oData.offsetHeight + this.Chart.oData.scrollTop){this.Chart.divInfo.style.top = (posY - this.Chart.divInfo.lastChild.offsetHeight - 10 - this.Chart.heightTaskItem) + "px"}else {this.Chart.divInfo.style.top = posY + "px"};if (this.Chart.divInfo.lastChild.offsetWidth + posX + 10 > this.Chart.oData.offsetWidth + this.Chart.oData.scrollLeft){this.Chart.divInfo.style.left = posX - (this.Chart.divInfo.lastChild.offsetWidth + posX + 20 - (this.Chart.oData.offsetWidth + this.Chart.oData.scrollLeft)) + "px"}else {this.Chart.divInfo.style.left = posX + "px"}}
        GanttError.prototype._init = function () {
            this._errors[0] = "连接错误";
            this._errors[1] = "不能连接";
            this._errors[2] = "服务器错误";
            this._errors[3] = "路径为空";
            this._errors[4] = "文件名为空";
            this._errors[5] = "文件 (%0) 未找到";
            this._errors[6] = "完成度必须是数值";
            this._errors[7] = "完成度必须 <= 100";
            this._errors[8] = "完成度必须 >= 0";
            this._errors[9] = "增加任务 (%0) 的周期";
            this._errors[10] = "减少任务 (%0) 的周期";
            this._errors[11] = "增加子任务 (%0) 的开始时间";
            this._errors[12] = "减少任务 (%0) 的开始时间";
            this._errors[13] = "The project (%0) is added";
            this._errors[14] = "Start Date of the project < start Date of the control";
            this._errors[15] = "任务 (%0) 不能是前置任务 (%1) 的子任务";
            this._errors[16] = "前置任务 (%0) 的终止时间 > 子任务 (%1) 的开始时间";
            this._errors[17] = "The Predecessor (%0) task does not exist";
            this._errors[18] = "The EST of task (%0) < start date of the control";
            this._errors[19] = "父任务 (%0) 的终止时间 < 子任务 k(%1) 的终止时间";
            this._errors[20] = "任务 (%0) 的开始时间 < 父任务 (%1) 的开始时间";
            this._errors[21] = "父任务 (%0) 不存在";
            this._errors[22] = "The task (%0) is added";
            this._errors[23] = "The project (%0) is added";
            this._errors[24] = "任务 (%0) 的开始时间 < 项目 (%1) 的开始时间";
            this._errors[25] = "父任务 (%0) 的开始时间不能为空";
            this._errors[26] = "前置任务 (%0) 位置错误. 请减少前置任务 (%0) 的周期或增加子任务 (%1) 的开始时间";
            this._errors[27] = "前置任务 (%0) 不存在";
            this._errors[28] = "增加父任务 (%0) 的周期或减少子任务 (%1) 的开始时间或减少子任务 (%1) 的周期";
            this._errors[29] = "减少父任务 (%0) 的开始时间或增加子任务 (%1) 的开始时间";
            this._errors[30] = "任务 (%0) 不存在";
            this._errors[31] = "项目 (%0) 不存在";
            this._errors[32] = "前置任务 (%0) 和子任务 (%1) 应该有相同的父任务";
            this._errors[33] = "减少父任务 (%0) 的开始时间或增加子任务 (%1) 的开始时间";
            this._errors[34] = "任务 (%0) 的开始时间 < 项目 (%1) 的开始时间";
            this._errors[35] = "完成度必须介于0到100之间";
            this._errors[36] = "You may not connect a task to itself.";
            this._errors[37] = "Cannot parse this XML string."
        };
        /**
         *通过甘特图样式显示指定项目的任务信息
         * @param taskInfo_gantt
         */
        function showTaskInfoByGantt(){
            var gantt = new GanttChart();
            gantt.setCorrectError(true)
            gantt.shortMonthNames=["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
            gantt.setImagePath("${ctx}/js/gantt/imgs/");
            gantt.setEditable(true);
//            gantt.clearItems("test_gantt");
//            gantt.setWidth("800");
            gantt.create('GanttDiv');
            gantt.loadData('${ctx}/ext/com.cinsea.project.ext.ProjectAction?action=selectTask&prjid=<%=projectid%>&',true,true);
        }

        $().ready(function(){
            showTaskInfoByGantt();

        });


    </script>
</head>
<body>

<div style="width:950px; height:620px; position:relative" id="GanttDiv"></div>

</body>
</html>
